<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

// namespace Home\Controller;
// use OT\DataDictionary;
namespace Admin\Controller;
/**
 * 前台首页控制器
 * 主要获取首页聚合数据
 */
class CustomermanagementController extends AdminController {
    
	//展位管理
	public function customer_management(){
        $map = array();
		$name       =   I('name');
        //$map  = array('status' => 1);
        //if(isset($_GET['name'])){
			//这里实现静态页面传递过来的值，然后进行数据模糊查询
        //    $map['name']    =   array('like', '%'.(string)I('name').'%');
       // }
	   if(is_numeric($name)){
			$map['uid|name']=array(intval($name),array('like','%'.$name.'%'),'_multi'=>true);//'_multi'=>true表示多条件匹配
		}else{
		    $map['name']=array('like','%'.(string)$name.'%');
		}
		$lists = $this->lists('Customer_info',$map,'uid asc');
		//var_dump($lists);exit;
    	$this->assign('customermanagement',$lists);
	    $this->display();
	}
	//删除
	 // public function del(){
  //       $id = array_unique((array)I('uid',0));

  //       if ( empty($id) ) {
  //           $this->error('请选择要操作的数据!');
  //       }

  //       $map = array('uid' => array('in', $id) );
  //       if(M('Customer_info')->where($map)->delete()){
  //           S('DB_CONFIG_DATA',null);
  //           //记录行为
  //           action_log('update_config','Customer_info',$id,uid);
  //           $this->success('删除成功！');
  //       } else {
  //           $this->error('删除失败！');
  //       }
  //    }

	 //屏蔽,开启，删除，这一些删除比较简单而且简洁，上面那个方法比较麻烦
	 public function changestatus($method=null){
        $id=array_unique((array)I('uid',0));
        $id=is_array($id) ? implode(',',$id) : $id;
        //var_dump($id);exit;
        if(empty($id)){
            $this->error('请选择要操作的数据！');
        }
        $map['uid']=array('in',$id);
        switch(strtolower($method)){
            case 'forbidcustomer':
                $this->forbid('Customer_info',$map);
                break;
            case 'resumecustomer':
                $this->resume('Customer_info',$map);
                break;
            case 'deletecustomer':
                $this->delete('Customer_info',$map);
                break;
            default:
                $this->error('非法参数');

        }
	    
	 
	 }

	 //排序
	 
	
			
  


}




?>